<template>
  <el-dialog width="80%" class="skus-select" lock-scroll="false" :visible="dialogShow" title="规格选择" top="10vh">
    <el-container>
      <el-aside>
        <el-menu class="aside-list">
          <el-menu-item v-for="item in skuList" :key="item.id">{{ item.name }}</el-menu-item>
          <div class="pagination">
            <el-pagination background layout="prev, next" :total="params.totalCount" />
          </div>
        </el-menu>
      </el-aside>
      <el-main>
        1
      </el-main>
    </el-container>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" size="small">确定</el-button>
      <el-button>取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getSkuList } from '@/api/skus'
export default {
  name: 'SkusSelect',
  props: {
    dialogShow: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      skuList: null,
      params: {
        page: 1,
        totalCount: null
      }
    }
  },
  created() {
    this.getSkuList()
  },
  methods: {
    async getSkuList() {
      try {
        const { list, totalCount } = await getSkuList(this.params.page, 8)
        this.skuList = list
        this.params.totalCount = totalCount
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.skus-select {
  .el-container {
    width: 100%;
    height: 100%;

    .el-aside {
      background-color: unset;
      border: solid 1px #e6e6e6;
      padding: 0;
      overflow: unset;
      height: 100%;

      .el-menu {
        position: relative;
        overflow: auto;
        height: 100%;

        .el-menu-item {
          border-bottom: 1px solid #e6e6e6;
          height: 45px;
          line-height: 45px;
        }

        .pagination {
          display: flex;
          justify-content: center;
          align-items: center;
          height: 50px;
          width: 100%;
          margin: 0;
          position: sticky;
          bottom: 0;
        }
      }
    }

  }

}
</style>
